<template>
	<view class="wrap">
		<u-list @scrolltolower="onLoadPage">
			<view class="card" v-for="(item, index) in state.list" :key="index" @click="to(item)">
				<view class="master">{{ item.formInstanceName }}</view>
				<view class="apply-info">
					<view class="item">
						<view class="label">申请人</view>
						<view>{{ item.applyUserName }}</view>
					</View>
					<view class="item">
						<view class="label"><Label>申请部门</Label></view>
						<view>{{ item.applyDeptName }}</view>
					</view>
					<View class="item">
						<view class="label"><Label>申请时间</Label></view>
						<view>{{ item.applyDateTime.substring(0,10) }}</view>
					</view>
				</view>
				<view class="tail">
					<view>编号：{{ item.formInstanceCode }}</view>
					<view>{{ item.applyDateTime.substring(0,16) }}</view>
				</view>	
			</view>
		</u-list>
	</view>
</template>

<script lang="ts" setup>
import { onLoad } from "@dcloudio/uni-app"
import { reactive } from 'vue'
import { request } from '../../utils/request'

const state = reactive({ 
	list: [] as any[],
	total: 0,
	pageNum: 1,
	pageSize: 16
})

const getData = () => {
	request.get('/flw/form-instance/my-approve/page?pageNum=1&pageSize=16', { params: { state: 1 } }).then((resp: any) => {
		if (resp.success) {
			state.list = resp.data.list
		}
	})
}

onLoad(() => {
	getData()
})

const onLoadPage = () => {
	if (state.total < state.list.length) {
		state.pageNum = state.pageNum + 1
		getData()
	}
}

const to = (item: any) => {
	uni.navigateTo({
		url: `/pages/approve/form?fid=${item.formInstance.formInstanceId}`,
	})
}

</script>


<style lang="scss" scoped>
.wrap {
	background: #f8f8f8;
}
.card {
	padding: 20rpx;
	border-radius: 12rpx;
	box-shadow: 0 20rpx 20rpx rgba(0, 0, 0, 0.05);
	background: white;
	margin: 20rpx 10rpx;
	.master {
		font-size: 32rpx;
		margin: 10rpx 0;
	}
	.label {
		color: rgba(0, 0, 0, 0.45);
		font-size: 24rpx;
		margin-bottom: 6rpx;
	}
	.tail {
		margin-top: 10rpx;
		color: rgba(0, 0, 0, 0.45);
		font-size: 24rpx;
		display: flex;
		justify-content: space-between;
	}
	.apply-info {
		display: flex;
		background: #F4F4F4;
		padding: 20px;
		font-size: 28rpx;
		.item {
			flex: 1;
			text-align: center;
		}
	}
}
</style>

